1
general::
Punish in order to prevent a recurrence of bad behavior. For example, Timmy set the wastebasket on fire; that should teach him a lesson about playing with matches. This term uses lesson in the sense of "a punishment or rebuke," a usage dating from the late 1500s. Also see LEARN ONE'S LESSON.
American Heritage Idioms
2
general::
Phrase(s): teach someone a lesson
to get even with someone for bad behavior. • John tripped me, so I punched him. That ought to teach him a lesson. • That taught me a lesson. I won’t do it again.
McGrawhill's American Idioms And Phrasal Verbs